<!DOCTYPE html>
<html>
<head>
    <title>我的私信</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/strategyCatalogs.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>


    <script>
        $(function () {
            //取出用户
            var user =  JSON.parse(sessionStorage.getItem("user"));
            //通过用户查询私信列表
            //发送请求查询私信
            $.get("/messages/"+user.id, function (data) {
                if(data.length>0){
                    //渲染数据
                    var json={list:data};
                    $("#receivers").renderValues(json,{
                        getHref: getHref
                    });
                }else{
                    $(document).dialog({
                        titleText: "温馨提示",
                        content: "亲,没有新消息呀",
                        //onClosed弹框关闭之后执行
                        onClosed:function () {
                            //没有结果就返回上一级页面
                            window.history.go(-1);
                        }
                    });
                }


            });




        });
    </script>
</head>

<body>



<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="/mine/message.html">
                <span><i class="fa fa-chevron-left" ></i></span>
            </a>
        </div>
        <div class="col">
            <span>我的私信</span>
        </div>
        <div class="col"></div>
    </div>
</div>


<div id="receivers">
    <div render-loop="list">
        <ul class="list-group">
            <a  render-fun="getHref" render-key="list.id" data-url="/mine/chart.html?id=">
                <li class="list-group-item d-flex justify-content-between align-items-center">
                    <div class="item">
                        <img  class="rounded-circle" render-src="list.headImgUrl" width="30px">
                        <span render-html="list.nickName"></span>
                        <span  class="badge badge-danger badge-pill" render-html="list.number"></span>
                    </div>
                </li>
            </a>
        </ul>
    </div>
</div>
</body>
</html>

